import request from '@/utils/request'

// 获取员工简单列表
export const getEmployeeSimple = () => {
  return request({
    url: '/sys/user/simple'
  })
}
// 获取员工列表
export function getEmployeeList(params) {
  return request({
    url: '/sys/user',
    params
  })
}
// 删除员工
export const delEmployee = (id) => {
  return request({
    url: `/sys/user/${id}`,
    method: 'DELETE'
  })
}

// 新增员工
export const addEmployee = (data) => {
  return request({
    url: '/sys/user',
    method: 'POST',
    data
  })
}
// 批量导入员工
export const importEmployee = (data) => {
  return request({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}
// 保存员工基本信息
export const saveUserDetailById = (data) => {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'PUT',
    data
  })
}
// 获取员工个人信息
export const getPersonalDetail = (id) => {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}
// 保存员工个人信息
export const updatePersonal = (data) => {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'PUT',
    data
  })
}
// 获取员工岗位信息
export const getJobDetail = (id) => {
  return request({
    url: `/employees/${id}/jobs`
  })
}
// 保存员工岗位信息
export const updateJob = (data) => {
  return request({
    url: `/employees/${data.userId}/jobs`,
    method: 'PUT',
    data
  })
}
// 给员工分配角色
export const assignRoles = (data) => {
  return request({
    url: '/sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
